package com.aigou.admin.aigouspringboot.controller.user;


import com.aigou.admin.aigouspringboot.common.LogScope;
import com.aigou.admin.aigouspringboot.entity.Order;
import com.aigou.admin.aigouspringboot.entity.Product;
import com.aigou.admin.aigouspringboot.entity.ReceivingAddress;
import com.aigou.admin.aigouspringboot.entity.dto.ProductQueryDTO;
import com.aigou.admin.aigouspringboot.entity.vo.OrderVO;
import com.aigou.admin.aigouspringboot.result.Result;
import com.aigou.admin.aigouspringboot.service.OrderService;
import com.github.pagehelper.PageInfo;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController("userOrderController")
@RequestMapping("/user/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @GetMapping("/{userId}")
    @LogScope(title = "订单管理模块", content = "根据user_id查询订单信息")
    public Result<PageInfo<OrderVO>> selectByUserId(@PathVariable String userId, @RequestParam Integer current) {
        PageInfo<OrderVO> orderList = orderService.selectByUserId(userId,current);
        return Result.success(orderList);
    }
    @GetMapping("/select/{userId}")
    public Result<PageInfo<OrderVO>> select(@PathVariable String userId,
                                    @RequestParam(value = "current", defaultValue = "1") int current,
                                    @RequestParam(value = "productName", required = false) String productName) {
        Map<String, Object> params = new HashMap<>();
        params.put("current", current);
        params.put("productName", productName);
        PageInfo<OrderVO> orders = orderService.selectProductListByPage(userId, params);
        return Result.success(orders);
    }

}
